"""
模拟用于检索增强生成（RAG）的知识库。
本模块模仿外部数据源，如课程目录、旅游产品等。
"""

# 1. “学习数据分析”领域的知识库
DATA_ANALYSIS_KB = {
    "courses": [
        {"id": "DA001", "title": "Python零基础入门", "category": "编程基础", "difficulty": "初级", "duration_hours": 20, "description": "掌握Python编程的基础知识，这是任何数据分析师必备的第一步。"},
        {"id": "DA002", "title": "面向数据科学的Python高级编程", "category": "编程进阶", "difficulty": "中级", "duration_hours": 35, "description": "深入学习NumPy, Pandas, 和 Matplotlib等库。"},
        {"id": "DA003", "title": "SQL与数据库入门", "category": "数据管理", "difficulty": "初级", "duration_hours": 15, "description": "学习如何使用SQL在关系型数据库中查询和管理数据。"},
        {"id": "DA004", "title": "数据分析师的实用SQL技巧", "category": "数据管理", "difficulty": "中级", "duration_hours": 30, "description": "专注于复杂查询、窗口函数和性能优化。"},
        {"id": "DA005", "title": "数据分析统计学基础", "category": "理论", "difficulty": "初级", "duration_hours": 25, "description": "理解支撑数据分析的核心统计学概念。"},
        {"id": "DA006", "title": "机器学习概论", "category": "机器学习", "difficulty": "中级", "duration_hours": 40, "description": "介绍回归、分类和聚类等关键的机器学习算法。"},
        {"id": "DA007", "title": "数据分析师作品集项目", "category": "项目", "difficulty": "高级", "duration_hours": 50, "description": "一个指导性的项目，用于构建一个真实世界的数据分析作品集。"},
        {"id": "DA008", "title": "数据分析师求职攻略", "category": "职业发展", "difficulty": "所有级别", "duration_hours": 10, "description": "关于简历制作、面试技巧和行业人脉建设的建议。"}
    ]
}

# 2. “规划一次户外探险旅行”领域的知识库
OUTDOOR_TRIP_KB = {
    "destinations": [
        {"id": "DEST01", "name": "美国黄石国家公园", "best_season": "夏季", "activities": ["徒步", "野生动物观察", "看间歇泉"]},
        {"id": "DEST02", "name": "加拿大班夫国家公园", "best_season": "夏季/冬季", "activities": ["徒步", "滑雪", "皮划艇"]},
        {"id": "DEST03", "name": "巴塔哥尼亚, 智利/阿根廷", "best_season": "秋季", "activities": ["徒步", "冰川徒步", "摄影"]}
    ],
    "gear": [
        {"id": "GEAR01", "name": "防水徒步鞋", "category": "鞋履", "for_kids": True},
        {"id": "GEAR02", "name": "全天候帐篷（4人）", "category": "住宿", "for_kids": True},
        {"id": "GEAR03", "name": "急救包", "category": "安全", "for_kids": True},
        {"id": "GEAR04", "name": "便携GPS导航仪", "category": "导航", "for_kids": False}
    ],
    "activities": [
        {"id": "ACT01", "name": "预订有向导的野生动物之旅", "type": "预订", "related_destination": "黄石"},
        {"id": "ACT02", "name": "预订露营地", "type": "预订", "related_destination": "所有"},
        {"id": "ACT03", "name": "检查签证和旅行证件", "type": "准备", "related_destination": "国际"}
    ]
}

def retrieve_knowledge(domain: str, query: str = "") -> dict:
    """
    模拟RAG系统的检索过程。
    在真实系统中，这里会涉及向量搜索或语义搜索。
    """
    print(f"--- [RAG] 正在为领域检索知识: '{domain}' ---")
    if domain.lower() == "data_analysis":
        return DATA_ANALYSIS_KB
    elif domain.lower() == "outdoor_trip":
        return OUTDOOR_TRIP_KB
    else:
        return {"error": "未找到指定领域"}

